﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ChEngine
{
    public partial class NegamaxEngine
    {
        const int MaxKiller = 2;
        Dictionary<BitMove, BitMove>[,] killerMoves = new Dictionary<BitMove, BitMove>[20,2];
        bool IsKiller(BitMove bm,int depth,Side color)
        {
            int index = 0;
            if (color == Side.Black)
                index = 1;
            if (depth >= killerMoves.Length)
                return false;
            else
                return killerMoves[depth,index].ContainsKey(bm);
        }
        void SetKiller(BitMove bm, int depth,Side color)
        {
            int index = 0;
            if (color == Side.Black)
                index = 1;
            if (depth >= killerMoves.Length)
                return;
            else
            {
                Dictionary<BitMove, BitMove> dict = killerMoves[depth,index];
                if (dict.Keys.Count > 5)
                {
                    foreach (BitMove old in dict.Keys)
                    {
                        dict.Remove(old);
                        break;
                    }
                }
                dict[bm] = bm;
            }

        }
    }
}
